package com.sjb.training.lc;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 有点儿意思
 * @Description:
 */
public class TheLongestPalindrom {
    public static void main(String[] args) {
        String s = "abcccccdd";
        int palindrome = longestPalindrome(s);
        System.out.println(palindrome);
    }


    public  static int longestPalindrome(String s) {
        char[] occurs = new char[128];
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            occurs[c]++;
            if (occurs[c] == 2){
                ans += 2;
                occurs[c] = 0;
            }
        }
        if (ans < s.length()){
            ans ++;
        }
        return ans;
    }
}
